package pyrachnid.model;

import java.util.ArrayList;

import pyrachnid.ctrl.Observer;


public abstract class Observable {
	protected ArrayList<Observer> _observer;

	public Observable() {
		_observer = new ArrayList<Observer>();
	}

	public void attach(Observer p_observable) {
		_observer.add(p_observable);
	}


	public void detach(Observer p_observable) {
		_observer.remove(p_observable);
	}
	

    public void detachAll() {
       _observer.clear();
	}
	
	
	public void notifyObserver(Object p_o, String p_arg) {
	        for(int i = 0; i < _observer.size(); i++) {
	                _observer.get(i).update(p_o, p_arg);
	        }
	}

}